<body>

	<div class="admin-biaogelist">
		<div class="listbiaoti am-cf">
			<ul class="am-icon-flag on">销售列表</ul>
			<dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">销售列表</a></dl>
		</div>
		<div class="fbneirong">

			<div class="zuo" style="line-height:21px;">销售姓名：</div>
			<input type="text" name="username">
			<input type="button" value="查找"   class="search am-btn am-btn-secondary am-radius " >
            <input type="button" value="新增销售"   class="addsale am-btn am-btn-secondary am-radius " >
			<br />
			<form class="am-form am-g">
				<table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
					<thead>
						<tr class="am-success">
                            <th class="table-check"><input type="checkbox" /></th>
                            <th class="table-type">用户ID</th>
							<th class="table-type">用户名</th>
							<th class="table-type">商家数</th>
                            <th class="table-type">推广奖励</th>
							<th class="table-type">今日新增</th>
							<th class="table-type"style="width: 400px;">邀请链接</th>
						</tr>

                    <tbody class="impowdith">
                    </tbody>
					</thead>
				</table>
			</form>
		</div>
	</div>
</body>

</div>
</html>


<script>




   var salerlist=$("#salerlist").html();


    var on_request=false;
    var page=1;



    $(".search").click(function () { page=1
        GetAllSaleList();
    });


   adduser();
   /**
    * 新增用户
    */
   function  adduser() {
       $(".addsale").click(function () {
           layer.open({
               title: '新增销售',
               btn: '确认',
               area: ['500px', '300px'],
               content: ' <form action="" method="post" id="new-zf-psd">\n' +
                   '        <div>\n' +
                   '            <label for="">账户名：</label><input type="text"   name="username"  value="">\n' +
                   '        </div>\n' +
                   '        <div>\n' +
                   '            <label for="">密码：</label><input type="text"   name="password"  value="" >\n' +
                   '        </div>\n' +
                   '        <div>\n' +
                   '            <label for="">手机：</label><input type="text"   name="phone"  value="" >\n' +
                   '        </div>\n' +
                   '    </form>',
               yes: function () {
                   var url = "<?php echo base_url(); ?>/Customer/adduser";

                   var username=$("#new-zf-psd input[name='username']").val();
                   var password=$("#new-zf-psd input[name='password']").val();
                   var phone=$("#new-zf-psd input[name='phone']").val();
                   var group=6;
                   var postdata = {
                       'username': username,
                       'password': password,
                       'phone': phone,
                       'group': group
                   };
                   $.post(url, postdata, function (data) {
                       on_request = false;
                       if(data.code==0){
                           layer.msg("添加成功",{
                               time: 2000, //2s后自动关闭
                               /*   btn: ['明白了', '知道了', '哦']*/
                           });
                           GetALLuserList();

                       }else{
                           layer.msg(data.msg);
                       }

                   }, 'json');

               }
           });




       });


   }


   function setlisthtnml(data) {
        var html = "";
        if (data.list.length > 0) {
            $.each(data.list, function (key, value) {
                html = html +
                    '<tr user_id="'+value.id+'"><td><input type="checkbox" /></td>\n' +
                    '<td>' + value.id + '</td>\n' +
                    '<td>' + value.username + '</td>\n' +
                    '<td>' + value.extension_nub + '</td>\n' +
                    '<td>' + value.extension + '</td>\n' +
                    '<td>' + value.extension_nub_day + '</td>\n' +
                    '<td ><input  style="width: 390px;" value="' + value.link + '" ></td>\n' +


                    '</tr>';
            });
            $(".impowdith").html(html);
            $('#Pagination').show();

        } else {
            html += '<li><div style="width:100%;text-align:center;">&nbsp暂无数据</div></li>';
            $(".impowdith").html(html);
            $('#Pagination').hide();
        }
    }

   GetAllSaleList();

    function GetAllSaleList() {
        var url = "<?php echo base_url(); ?>/Customer/GetAllSaleList";
        var username=$("input[name='username']").val();

        var postdata = {
            'page': page,
            'eapge': 15,
            'username': username

        };
        $.post(url, postdata, function (data) {
            on_request = false;
            setlisthtnml(data);
            setPagination("Pagination", data.count, page, data.epage, function (clickPage) {
                page = parseInt(clickPage) + 1;
                GetAllSaleList();
            });
        }, 'json');

    }






</script>